<div class="portlet light bordered" style="margin: 15px;">
    <div class="portlet-title">
        <div class="caption">
            <span class="caption-subject bold">General Pack Task: {{task.id}}</span>
        </div>
         <div class="actions">
             <button type="button" class="btn blue" ng-show="task.status == 'Closed'" ng-click="reopenTask(task)">Reopen</button>

             <button ng-click="printShippingLabel(task.orderIds)" class="btn gray right">
                <span class="glyphicon glyphicon-print" aria-hidden="true"></span> Print Shipping Label
             </button>
             <button ng-click="printMultipleOrderPackingList(task.orderIds)" class="btn gray right">
                 <span class="glyphicon glyphicon-print" aria-hidden="true"></span> Multiple Order Packing list
             </button>
        </div>
    </div>
    <div class="portlet-body  form form-horizontal">
        <div class="form-group">
            <span class="col-md-3"><b>Order ID: </b>
             <span ng-repeat="orderId in task.orderIds">
                    <a ng-href="{{'#/wms/outbound/order/' + orderId}}" target="_blank">{{orderId}}</a>
             </span>
            </span>
            <span class="col-md-3"><b>Assignee: </b>{{task.assignee.firstName}}{{task.assignee.lastName}}</span>
            <span class="col-md-3"><b>Status: </b>{{task.status}}</span>
            <span class="col-md-3"><b>Priority: </b>{{task.priority}}</span>
        </div>
        <div class="form-group">
            <span class="col-md-3"><b>MADB: </b>{{task.mabd | amDateFormat:'YYYY-MM-DD HH:mm:ss'}}</span>
             <span class="col-md-9"><b>locationIds: </b>
                <span ng-repeat="locationId in task.locationIds">
                   {{locationId}}
                </span>
            </span>
        </div>
        <div class="form-group">
            <div class="col-md-3">
                <b>Start Time:</b>
                <span>{{task.startTime}}</span>
            </div>
            <div class="col-md-3">
                <b>End Time:</b>
                <span>{{task.endTime}}</span>
            </div>
            <span class="col-md-3"><b>Created Time: </b>{{task.createdWhen | amDateFormat:'YYYY-MM-DD HH:mm:ss'}}
                &nbsp;<span ng-show="task.createdBy">({{task.createdBy}})</span></span>
            <span class="col-md-3"><b>Updated Time: </b>{{task.updatedWhen | amDateFormat:'YYYY-MM-DD HH:mm:ss'}}
                &nbsp;<span ng-show="task.updatedBy">({{task.updatedBy}})</span></span>
        </div>
        <div class="form-group" style="margin-bottom: 20px;">
            <span class="col-md-12">
                <b>Description:</b> {{task.description}}
            </span>
        </div>

        <div class="tabbable-custom" style=" overflow: visible" ng-if="task!=null">
            <ul class="nav nav-tabs">
                <li ng-class="{'active':activetab == 'itemLines'}" >
                    <a data-toggle="tab" ng-click="changeTab('itemLines')"> Item Lines </a>
                </li>
                <li ng-class="{'active':activetab == 'packHistories'}">
                    <a data-toggle="tab" ng-click="changeTab('packHistories')"> Pack History </a>
                </li>
            </ul>
            <div class="tab-content" style="padding:15px;">
                <div ng-class="{'active':activetab == 'itemLines'}" class="tab-pane">
                    <div ng-repeat="order in task.orderViews track by $index" style="padding:10px 0px;">
                        <div class="row">
                            <div class="col-md-4" style="font-size: 16px;">
                                <a ng-click="orderClick(order)"><span><b>{{order.orderId}}</b></span></a>
                                <span>(<b>Status:</b>{{order.status}})</span>
                            </div>
                            <div class="col-md-8" style="text-align: right;">
                                <button ng-click="printOrderPackingListPrint(order.orderId)"class="btn gray right">
                                    <span class="glyphicon glyphicon-print" aria-hidden="true"></span>
                                    Packing List
                                </button>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-4">
                                <label class="bold">Materials:</label>
                                <label ng-repeat="m in order.materials">{{itemSpecMap[m.itemSpecId].name}}&nbsp;&nbsp;</label>
                            </div>
                            <div class="col-md-4">
                                <label class="bold">Package:</label>
                                <label>{{itemSpecMap[order.packagingType.itemSpecId].name}}&nbsp;
                                    <b>{{order.packages.length}}</b>&nbsp;packages</label>
                            </div>
                        </div>
                        <div class="table-scrollable">
                            <table class="table table-striped table-hover">
                                <thead>
                                <tr>
                                    <th> Item </th>
                                    <th> Unit </th>
                                    <th> Qty </th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr ng-repeat="itemLine in order.itemLines">
                                    <td><item-display item="itemSpecMap[itemLine.itemSpecId]"></item-display></td>
                                    <td> {{itemUnitMap[itemLine.unitId].name}} </td>
                                    <td> {{itemLine.qty}} </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <div ng-class="{'active':activetab == 'packHistories'}" class="tab-pane">
                    <div class="table-scrollable" style="border: hidden;">
                        <table class="table table-striped table-hover">
                            <thead>
                            <tr>
                                <th> Item </th>
                                <th> From LP </th>
                                <th> To LP </th>
                                <th> Is Entire LP Pick </th>
                                <th> QTY </th>
                                <th> Unit </th>
                                <th> Packed By </th>
                                <th> Packed When </th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr ng-repeat="packHistory in packedHistoryPage">
                                <td><item-display item="packHistory"></item-display></td>
                                <td>{{packHistory.fromLPId}}</td>
                                <td>{{packHistory.toLPId}}</td>
                                <td>{{packHistory.isEntireLPPack?"Yes":"No"}}</td>
                                <td>{{packHistory.qty}}</td>
                                <td>{{packHistory.unitName}}</td>
                                <td>{{packHistory.packedBy}}</td>
                                <td>{{packHistory.packedWhen | amDateFormat:'YYYY-MM-DD HH:mm:ss'}}</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <pager total-count="packedHistoryTotalCount" page-size="pageObj.pageSize"  load-content="loadContent(currentPage)"></pager>
                </div>
            </div>
        </div>


        <div class="panel panel-default"  ng-repeat="step in task.steps">
            <div class="panel-heading">

                <div class="panel-title" style="display:block;float:left;line-height:34px;"> STEP | {{step.name}}</div>
                <div class="actions" style="text-align: right;">
                    <button type="button" class="btn yellow" permission-check="{{'task::generalPackTask_write'}}" update-step-assignees task-step="step">Edit Assignees</button>
                    <button type="button" class="btn blue" ng-click="reopenStep(step)"
                            permission-check="{{'task::generalPackTask_write'}}"
                            ng-disabled="step.status != 'Done' && step.status != 'Force Closed'">Reopen
                    </button>
                </div>
            </div>
            <div class="panel-body">
            <div class="tabbable-custom" style="margin-bottom: 0px; overflow: visible">
                <ul class="nav nav-tabs">
                    <li ng-class="{'active':activeStepTabs[step.id] == 'content'}">
                        <a data-toggle="tab" ng-click="changeStepTab('content', step.id)"> Content </a>
                    </li>
                    <li ng-class="{'active':activeStepTabs[step.id] == 'stepException'}">
                        <a data-toggle="tab" ng-click="changeStepTab('stepException', step.id)"> Exception </a>
                    </li>
                </ul>
                <div class="tab-content" style="padding:15px;">
                    <div ng-class="{'active':activeStepTabs[step.id] == 'content'}" class="tab-pane ">
                        <div ng-include="'wms/task/common/template/genericStep.html'"></div>
                    </div>
                    <div ng-class="{'active':activeStepTabs[step.id] == 'stepException'}" class="tab-pane ">
                        <div style="padding: 20px 20px;">
                            {{step.forceCloseReason}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
        </div>

    </div>
</div>
